﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ATA.Winforms
{
    public partial class frmChietkhau : Form
    {
        public frmChietkhau()
        {
            InitializeComponent();
        }

        public void SetTitleLable(string pv_strTitleLable)
        {
            this.lblDiscountTitle.Text = pv_strTitleLable;
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        public virtual void btnExportExcel_Click(object sender, EventArgs e)
        {
            try
            {
                // Displays a SaveFileDialog so the user can save the Image
                // assigned to Button2.
                SaveFileDialog v_saveFileDialog = new SaveFileDialog();
                v_saveFileDialog.Filter = "Excel File|*.xls";
                v_saveFileDialog.Title = "Save an Excel File";
                v_saveFileDialog.ShowDialog();

                // If the file name is not an empty string open it for saving.
                if (v_saveFileDialog.FileName != "")
                {
                    // Saves the Image via a FileStream created by the OpenFile method.
                    mainUltraGridExcelExporter.Export(grdResults, v_saveFileDialog.FileName);
                }

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

        public virtual void btnGenData_Click(object sender, EventArgs e)
        {

        }

        private void frmChietkhau_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                #region bind customer list
                
                cboCustomers.ValueMember = "AccountingObjectID";
                cboCustomers.DisplayMember = "AccountingObjectCode";
                cboCustomers.DataSource = Globals.gv_lsCustomers;
                cboCustomers.DisplayLayout.Bands[0].Columns["AccountingObjectID"].Hidden = true;
                cboCustomers.DisplayLayout.Bands[0].Columns["ParentAccountingObjectID"].Hidden = true;
                cboCustomers.DisplayLayout.Bands[0].Columns["AccountingObjectCode"].Header.Caption = "Mã KH";
                cboCustomers.DisplayLayout.Bands[0].Columns["AccountingObjectCode"].Width = 80;
                cboCustomers.DisplayLayout.Bands[0].Columns["AccountingObjectName"].Header.Caption = "Tên KH";
                cboCustomers.DisplayLayout.Bands[0].Columns["AccountingObjectName"].Width = 250;
                cboCustomers.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
                #endregion 
            }
        }

        private void cboCustomers_ValueChanged(object sender, EventArgs e)
        {
            txtCustomerName.Text = cboCustomers.SelectedRow.Cells["AccountingObjectName"].Value.ToString();
        }
    }
}
